CC = gcc
CFLAGS = -g -Wall -lpthread

# 生产者-消费者目标文件
PC_OBJS = mainProg.o ProducerConsumerUtilities.o Consumer.o Producer.o
# 读者-写者目标文件
RW_OBJS = mainRW.o ReaderWriterUtilities.o Reader.o Writer.o


# 编译生产者-消费者程序
producer_consumer: $(PC_OBJS)
	$(CC) $(CFLAGS) -o $@ $(PC_OBJS)

# 编译读者-写者程序
riter: $(RW_OBJS)
	$(CC) $(CFLAGS) -o $@ $(RW_OBJS)

# 生产者-消费者依赖
mainProg.o: mainProg.c ProducerConsumerUtilities.h Consumer.h Producer.h
ProducerConsumerUtilities.o: ProducerConsumerUtilities.c ProducerConsumerUtilities.h
Consumer.o: Consumer.c Consumer.h ProducerConsumerUtilities.h
Producer.o: Producer.c Producer.h ProducerConsumerUtilities.h

# 读者-写者依赖
mainRW.o: mainRW.c ReaderWriterUtilities.h Reader.h Writer.h
ReaderWriterUtilities.o: ReaderWriterUtilities.c ReaderWriterUtilities.h
Reader.o: Reader.c Reader.h ReaderWriterUtilities.h
Writer.o: Writer.c Writer.h ReaderWriterUtilities.h

clean:
	rm -f *.o producer_consumer reader_writer
